/*    */ package server.commands;
/*    */ 
/*    */ import tools.StringUtil;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CommandProcessorUtil
/*    */ {
/*    */   public static String joinAfterString(String[] splitted, String str) {
/* 11 */     for (int i = 1; i < splitted.length; i++) {
/* 12 */       if (splitted[i].equalsIgnoreCase(str) && i + 1 < splitted.length) {
/* 13 */         return StringUtil.joinStringFrom(splitted, i + 1);
/*    */       }
/*    */     } 
/* 16 */     return null;
/*    */   }
/*    */   
/*    */   public static int getOptionalIntArg(String[] splitted, int position, int def) {
/* 20 */     if (splitted.length > position) {
/*    */       try {
/* 22 */         return Integer.parseInt(splitted[position]);
/* 23 */       } catch (NumberFormatException nfe) {
/* 24 */         return def;
/*    */       } 
/*    */     }
/* 27 */     return def;
/*    */   }
/*    */   
/*    */   public static String getNamedArg(String[] splitted, int startpos, String name) {
/* 31 */     for (int i = startpos; i < splitted.length; i++) {
/* 32 */       if (splitted[i].equalsIgnoreCase(name) && i + 1 < splitted.length) {
/* 33 */         return splitted[i + 1];
/*    */       }
/*    */     } 
/* 36 */     return null;
/*    */   }
/*    */   
/*    */   public static Long getNamedLongArg(String[] splitted, int startpos, String name) {
/* 40 */     String arg = getNamedArg(splitted, startpos, name);
/* 41 */     if (arg != null) {
/*    */       try {
/* 43 */         return Long.valueOf(Long.parseLong(arg));
/* 44 */       } catch (NumberFormatException numberFormatException) {}
/*    */     }
/*    */ 
/*    */     
/* 48 */     return null;
/*    */   }
/*    */   
/*    */   public static Integer getNamedIntArg(String[] splitted, int startpos, String name) {
/* 52 */     String arg = getNamedArg(splitted, startpos, name);
/* 53 */     if (arg != null) {
/*    */       try {
/* 55 */         return Integer.valueOf(Integer.parseInt(arg));
/* 56 */       } catch (NumberFormatException numberFormatException) {}
/*    */     }
/*    */ 
/*    */     
/* 60 */     return null;
/*    */   }
/*    */   
/*    */   public static int getNamedIntArg(String[] splitted, int startpos, String name, int def) {
/* 64 */     Integer ret = getNamedIntArg(splitted, startpos, name);
/* 65 */     if (ret == null) {
/* 66 */       return def;
/*    */     }
/* 68 */     return ret.intValue();
/*    */   }
/*    */   
/*    */   public static Double getNamedDoubleArg(String[] splitted, int startpos, String name) {
/* 72 */     String arg = getNamedArg(splitted, startpos, name);
/* 73 */     if (arg != null) {
/*    */       try {
/* 75 */         return Double.valueOf(Double.parseDouble(arg));
/* 76 */       } catch (NumberFormatException numberFormatException) {}
/*    */     }
/*    */ 
/*    */     
/* 80 */     return null;
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\server\commands\CommandProcessorUtil.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */